home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir24 / psi110g.zip / AX25.H < prev    next >
C/C++ Source or Header  |  1994-04-17  |  10KB  |  295 lines

  1.  /* Mods by G1EMM */
  2. #ifndef _AX25_H
  3. #define _AX25_H
  4.   
  5. #ifndef _GLOBAL_H
  6. #include "global.h"
  7. #endif
  8.   
  9. #ifndef _IP_H
  10. #include "ip.h"
  11. #endif
  12.   
  13. #ifndef _MBUF_H
  14. #include "mbuf.h"
  15. #endif
  16.   
  17. #ifndef _IFACE_H
  18. #include "iface.h"
  19. #endif
  20.   
  21. #ifndef _SOCKADDR_H
  22. #include "sockaddr.h"
  23. #endif
  24.   
  25. /* AX.25 datagram (address) sub-layer definitions */
  26.   
  27. #define MAXDIGIS    7   /* Maximum number of digipeaters */
  28. #define ALEN        6   /* Number of chars in callsign field */
  29. #define AXALEN      7   /* Total AX.25 address length, including SSID */
  30. #define AXBUF       10  /* Buffer size for maximum-length ascii call */
  31.   
  32. #ifndef _LAPB_H
  33. #include "lapb.h"
  34. #endif
  35.   
  36. /* Bits within SSID field of AX.25 address */
  37. #define SSID        0x1e    /* Sub station ID */
  38. #define REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  39. #define E       0x01    /* Address extension bit */
  40. #define C       0x80    /* Command/response designation */
  41.   
  42. /* Our AX.25 address */
  43. extern char Mycall[AXALEN];
  44. extern char Bbscall[AXALEN];
  45.   
  46. /* List of AX.25 multicast addresses, e.g., "QST   -0" in shifted ASCII */
  47. extern char Ax25multi[][AXALEN];
  48. #define QSTCALL 0
  49. #define NODESCALL 1
  50. #define MAILCALL 2
  51. #define IDCALL 3
  52. /*currently not used in this code*/
  53. #define OPENCALL 4
  54. #define CQCALL 5
  55. #define BEACONCALL 6
  56. #define RMNCCALL 7
  57. #define ALLCALL 8
  58.   
  59. extern int Digipeat;
  60. extern int Ax25mbox;
  61.   
  62. /* Number of chars in interface field. The involved definition takes possible
  63.  * alignment requirements into account, since ax25_addr is of an odd size.
  64.  */
  65. #define ILEN    (sizeof(struct sockaddr) - sizeof(short) - AXALEN)
  66.   
  67. /* Socket address, AX.25 style */
  68. struct sockaddr_ax {
  69.     short sax_family;       /* 2 bytes */
  70.     char ax25_addr[AXALEN];
  71.     char iface[ILEN];       /* Interface name */
  72. };
  73.   
  74. /* Internal representation of an AX.25 header */
  75. struct ax25 {
  76.     char dest[AXALEN];      /* Destination address */
  77.     char source[AXALEN];        /* Source address */
  78.     char digis[MAXDIGIS][AXALEN];   /* Digi string */
  79.     int ndigis;         /* Number of digipeaters */
  80.     int nextdigi;           /* Index to next digi in chain */
  81.     int cmdrsp;         /* Command/response */
  82. };
  83.   
  84. /* C-bit stuff */
  85. #define LAPB_UNKNOWN        0
  86. #define LAPB_COMMAND        1
  87. #define LAPB_RESPONSE       2
  88.   
  89. /* AX.25 routing table entry */
  90. struct ax_route {
  91.     struct ax_route *next;      /* Linked list pointer */
  92.     char target[AXALEN];
  93.     struct iface *iface;
  94.     char digis[MAXDIGIS][AXALEN];
  95.     int ndigis;
  96.     char type;
  97. #define AX_LOCAL    1       /* Set by local ax25 route command */
  98. #define AX_AUTO     2       /* Set by incoming packet */
  99.     char mode;          /* Connection mode (G1EMM) */
  100. #define AX_DEFMODE  0       /* Use default interface mode */
  101. #define AX_VC_MODE  1       /* Try to use Virtual circuit */
  102. #define AX_DATMODE  2       /* Try to use Datagrams only */
  103. };
  104. #define NULLAXR ((struct ax_route *)0)
  105.   
  106. extern struct ax_route *Ax_routes;
  107. extern struct ax_route Ax_default;
  108.   
  109. /* AX.25 Level 3 Protocol IDs (PIDs) */
  110. #define PID_X25     0x01    /* CCITT X.25 PLP */
  111. #define PID_SEGMENT 0x08    /* Segmentation fragment */
  112. #define PID_TEXNET  0xc3    /* TEXNET datagram protocol */
  113. #define PID_LQ      0xc4    /* Link quality protocol */
  114. #define PID_APPLETALK   0xca    /* Appletalk */
  115. #define PID_APPLEARP    0xcb    /* Appletalk ARP */
  116. #define PID_IP      0xcc    /* ARPA Internet Protocol */
  117. #define PID_ARP     0xcd    /* ARPA Address Resolution Protocol */
  118. #define PID_RARP    0xce    /* ARPA Reverse Address Resolution Protocol */
  119. #define PID_NETROM  0xcf    /* NET/ROM */
  120. #define PID_NO_L3   0xf0    /* No level 3 protocol */
  121.   
  122. #define SEG_FIRST   0x80    /* First segment of a sequence */
  123. #define SEG_REM     0x7f    /* Mask for # segments remaining */
  124.   
  125. #define AX_EOL      "\r"    /* AX.25 end-of-line convention */
  126.   
  127. /* Link quality report packet header, internal format */
  128. struct lqhdr {
  129.     int16 version;      /* Version number of protocol */
  130. #define LINKVERS    1
  131.     int32   ip_addr;    /* Sending station's IP address */
  132. };
  133. #define LQHDR   6
  134. /* Link quality entry, internal format */
  135. struct lqentry {
  136.     char addr[AXALEN];  /* Address of heard station */
  137.     int32 count;        /* Count of packets heard from that station */
  138. };
  139. #define LQENTRY 11
  140.   
  141. /* Link quality database record format
  142.  * Currently used only by AX.25 interfaces
  143.  */
  144. struct lq {
  145.     struct lq *next;
  146.     char addr[AXALEN];  /* Hardware address of station heard */
  147.     struct iface *iface;    /* Interface address was heard on */
  148.     int32 time;     /* Time station was last heard */
  149.     int32 currxcnt; /* Current # of packets heard from this station */
  150.   
  151. #ifdef  notdef      /* Not yet implemented */
  152.     /* # of packets heard from this station as of his last update */
  153.     int32 lastrxcnt;
  154.   
  155.     /* # packets reported as transmitted by station as of his last update */
  156.     int32 lasttxcnt;
  157.   
  158.     int16 hisqual;  /* Fraction (0-1000) of station's packets heard
  159.              * as of last update
  160.              */
  161.     int16 myqual;   /* Fraction (0-1000) of our packets heard by station
  162.              * as of last update
  163.              */
  164. #endif
  165. };
  166. #define NULLLQ  (struct lq *)0
  167.   
  168. extern struct lq *Lq;   /* Link quality record headers */
  169.   
  170. /* Structure used to keep track of monitored destination addresses */
  171. struct ld {
  172.     struct ld *next;    /* Linked list pointers */
  173.     char addr[AXALEN];/* Hardware address of destination overheard */
  174.     struct iface *iface;    /* Interface address was heard on */
  175.     int32 time;     /* Time station was last mentioned */
  176.     int32 currxcnt; /* Current # of packets destined to this station */
  177. };
  178. #define NULLLD  (struct ld *)0
  179.   
  180. extern struct ld *Ld;   /* Destination address record headers */
  181.   
  182. #ifdef __GNUC__
  183. struct ax25_cb;           /* forward declaration */
  184. #endif
  185.   
  186. /* Linkage to network protocols atop ax25 */
  187. struct axlink {
  188.     int pid;
  189.     void (*funct) __ARGS((struct iface *,struct ax25_cb *,char *, char *,
  190.     struct mbuf *,int));
  191. };
  192. extern struct axlink Axlink[];
  193.   
  194. /* Codes for the open_ax25 call */
  195. #define AX_PASSIVE  0
  196. #define AX_ACTIVE   1
  197. #define AX_SERVER   2   /* Passive, clone on opening */
  198.   
  199. /* Max number of fake AX.25 interfaces for RFC-1226 encapsulation */
  200. #define NAX25       16
  201.   
  202. #define AXHEARD_PASS    0   /* Log both src and dest callsigns */
  203. #define AXHEARD_NOSRC   1   /* do not log source callsign */
  204. #define AXHEARD_NODST   2   /* do not log destination callsign */
  205. #define AXHEARD_NONE    3   /* do not log any callsign */
  206.   
  207. /* an call that should not be jump-started */
  208. struct no_js {
  209.     struct no_js *next;
  210.     char call[AXALEN];
  211. };
  212.   
  213. /* AX.25 protocol data kept per interface */
  214. struct ifax25 {
  215.     int paclen;
  216.     int lapbtimertype;
  217.     long irtt;
  218.     int version;
  219.     long t3;
  220.     long t4;
  221.     int n2;
  222.     int maxframe;
  223.     int pthresh;
  224.     int window;
  225.     long blimit;
  226.     long maxwait;   /* maximum backoff time */
  227.     char *bctext;
  228.     char cdigi[AXALEN];
  229. #ifdef MAILBOX
  230.     char bbscall[AXALEN];
  231. #endif
  232. };
  233.   
  234. /* In ax25.c: */
  235. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int,struct iface *));
  236. int ax_drop __ARGS((char *,struct iface *));
  237. struct ax_route *ax_lookup __ARGS((char *,struct iface *));
  238. void axip_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,int rxbroadcast));
  239. void ax_recv __ARGS((struct iface *,struct mbuf *));
  240. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  241. int del,int tput,int rel));
  242. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  243. struct mbuf *data));
  244. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  245. void axnl3 __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  246. char *dest,struct mbuf *bp,int mcast));
  247.   
  248. /* In ax25cmd.c: */
  249. void st_ax25 __ARGS((struct ax25_cb *axp));
  250. int axheard __ARGS((struct iface *ifp));
  251. void init_ifax25 __ARGS((struct ifax25 *));
  252.   
  253. /* In axhdr.c: */
  254. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  255. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  256.   
  257. /* In axlink.c: */
  258. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  259. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  260. void logsrc __ARGS((struct iface *iface,char *addr));
  261. void logdest __ARGS((struct iface *iface,char *addr));
  262. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  263. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  264. struct lq *al_lookup __ARGS((struct iface *ifp,char *addr,int sort));
  265.   
  266. /* In ax25user.c: */
  267. int ax25val __ARGS((struct ax25_cb *axp));
  268. int disc_ax25 __ARGS((struct ax25_cb *axp));
  269. int kick_ax25 __ARGS((struct ax25_cb *axp));
  270. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  271. int,int16,
  272. void (*) __ARGS((struct ax25_cb *,int)),
  273. void (*) __ARGS((struct ax25_cb *,int)),
  274. void (*) __ARGS((struct ax25_cb *,int,int)),
  275. int user));
  276. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  277. int reset_ax25 __ARGS((struct ax25_cb *axp));
  278. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  279.   
  280. /* In ax25subr.c: */
  281. int addreq __ARGS((char *a,char *b));
  282. struct ax25_cb *cr_ax25 __ARGS((char *local,char *remote,struct iface *iface));
  283. void del_ax25 __ARGS((struct ax25_cb *axp));
  284. struct ax25_cb *find_ax25 __ARGS((char *local,char *remote,struct iface *iface));
  285. char *pax25 __ARGS((char *e,char *addr));
  286. int setcall __ARGS((char *out,char *call));
  287.   
  288. /* In socket.c: */
  289. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  290. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  291. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  292. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  293.   
  294. #endif  /* _AX25_H */
  295.